<template>
  <div>
    <credit-file
      :view-mode="postdata.project_status === '3' && postdata.project_status === '1'"
      :related-id="id"
    ></credit-file>
    <!-- <div style="text-align: center;"
         class="bg-white mt-2 p-2">
      <el-button type="primary"
                 v-if="filsh"
                 class="btn-gd-width"
                 @click="UpdataFile">归档
      </el-button>

      <el-button type="primary"
                 v-else
                 @click="returnClose">完成
      </el-button>
    </div> -->
    <!-- <el-dialog title="提示"
               :visible.sync="dialogVisible"
               width="30%"
               :close-on-click-modal="false"
               :before-close="handleClose">
      <span>是否需要评级？</span>
      <span slot="footer"
            class="dialog-footer">
        <el-button @click="putReview('2')"
                   v-loading="saveLoading">不需要</el-button>
        <el-button type="primary"
                   @click="putReview('1')"
                   v-loading="saveLoading">评 级</el-button>
      </span>
    </el-dialog> -->
  </div>
</template>
<script>
import CreditFile from '@/credit/components/creditFile/Index'

export default {
  components: {
    CreditFile,
  },
  props: {
    file: Number,
  },
  data() {
    return {
      id: '',
      // dialogVisible: false,
      saveLoading: false,
      postdata: {},
    }
  },
  computed: {},
  watch: {
    file() {
      this.getData()
    },
  },
  created() {
    this.getData()
  },
  mounted() {},
  methods: {
    getData() {
      this.id = this.$route.query.id || sessionStorage.getItem('customer_related_id')
      this.$api
        .getData('credit', 'customer_related_view', {
          'customer_related_id.eq': this.id,
        })
        .then(res => {
          if (!res || !res.data) {
            return
          }
          this.postdata = res.data[0]
        })
    },
    // returnClose() {
    //   this.$emit('close', false)
    // },
    // UpdataFile() {
    //   const h = this.$createElement
    //   this.$msgbox({
    //     title: '提示',
    //     message: h('span', undefined, `确定归档？归档后不能再次修改`),
    //     showCancelButton: true,
    //     confirmButtonText: '确定',
    //     cancelButtonText: '取消',
    //     beforeClose: async (action, instance, done) => {
    //       if (action === 'confirm') {
    //         instance.confirmButtonLoading = true
    //         instance.confirmButtonText = '归档中...'
    //         const [res] = await this.$utils.promise(this.$api.updateData('credit', 'customer_related', this.id, { project_status: 2 }))
    //         instance.confirmButtonLoading = false
    //         instance.confirmButtonText = '确定'
    //         if (res) {
    //           this.$message.success('归档成功！')
    //           this.getinfoData()
    //           done()
    //         } else {
    //           this.$message.error('归档失败，请重试！')
    //         }
    //       } else {
    //         done()
    //       }
    //     }
    //   })
    // }
    // async putReview(val) {
    //   this.saveLoading = true
    //   const [res] = await this.$utils.promise(this.$api.updateData('credit', 'customer_related', this.id, {
    //     is_need_rating: val
    //   }))
    //   if (!res) {
    //     return this.$message.error('操作失败，请重试！')
    //   }
    //   this.$message.success('操作成功！')
    //   this.saveLoading = false
    //   this.handleClose()
    // },
    // Review() {
    //   this.dialogVisible = true
    // },
    // handleClose() {
    //   this.dialogVisible = false
    // }
  },
}
</script>
<style lang="scss" scoped></style>
